<%@ page language="java" import="com.google.gson.Gson" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="down3.biz.DnFile" %>
<%@ page import="down3.model.DnFileInf" %>
<%@ page import="org.apache.commons.lang.StringUtils" %>
<%@ page import="up7.utils.PathTool" %>
<%@ page import="java.net.URLEncoder" %>
<%
	out.clear();
	/*
		此页面主要用来向数据库添加一条记录。
		一般在 HttpUploader.js HttpUploader_MD5_Complete(obj) 中调用
		更新记录：
			2017-08-15 取消对redis的引用
			2016-01-08 规范json返回值格式和数据
			2012-06-29 增加创建文件逻辑，
			2012-05-24 完善
	*/
	String uid 		 = request.getParameter("uid");
	String id	 	 = request.getParameter("id");
	String f_id 	 = request.getParameter("f_id");
	String nameLoc   = request.getParameter("nameLoc");
	String pathLoc	 = request.getParameter("pathLoc");
	String fileUrl	 = request.getParameter("fileUrl");
	String lenSvr 	 = request.getParameter("lenSvr");
	String sizeSvr 	 = request.getParameter("sizeSvr");
	String cbk  	 = request.getParameter("callback");//jsonp
	pathLoc 		 = PathTool.url_decode(pathLoc);
	nameLoc		 	 = PathTool.url_decode(nameLoc);

	if (StringUtils.isBlank(uid)
		||StringUtils.isBlank(pathLoc)
		||StringUtils.isBlank(fileUrl)
		||StringUtils.isBlank(lenSvr))
	{
		out.write(cbk + "({\"value\":null}) ");
		return;
	}

	DnFileInf inf = new DnFileInf();
	inf.id		  = id;
	inf.f_id      = f_id;
	inf.uid       = uid;
	inf.nameLoc   = nameLoc;
	inf.pathLoc   = pathLoc;
	inf.fileUrl   = fileUrl;
	inf.lenSvr    = Long.parseLong(lenSvr);
	inf.sizeSvr   = sizeSvr;

	DnFile df = new DnFile();
	df.Add(inf);

	Gson gson = new Gson();
	String json = gson.toJson(inf);
	json = URLEncoder.encode(json,"UTF-8");
	json = json.replaceAll("\\+","%20");
	json = cbk + "({\"value\":\"" + json + "\"})";//返回jsonp格式数据。
	out.write(json);
%>